/*
 * NewProjectBox.java
 *
 * Created on 2008년 11월 22일 (토), 오후 11:22
 */

package collage;

import org.jdesktop.application.Action;

/**
 *
 * @author  Administrator
 */
public class NewProjectBox extends javax.swing.JDialog {
     private boolean newproj = false;
     private int w,h;
    /** Creates new form NewProjectBox */
    public NewProjectBox(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        canvasSizeButtonGroup = new javax.swing.ButtonGroup();
        jButton1 = new javax.swing.JButton();
        cancelButton = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        size4x6RadioButton = new javax.swing.JRadioButton();
        size5x7RadioButton = new javax.swing.JRadioButton();
        size8x10RadioButton = new javax.swing.JRadioButton();
        customRadioButton = new javax.swing.JRadioButton();
        customHSpinner = new javax.swing.JSpinner();
        customWSpinner = new javax.swing.JSpinner();
        heightLabel = new javax.swing.JLabel();
        widthLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N
        setResizable(false);

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(collage.CollageApp.class).getContext().getActionMap(NewProjectBox.class, this);
        jButton1.setAction(actionMap.get("okButton")); // NOI18N
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(collage.CollageApp.class).getContext().getResourceMap(NewProjectBox.class);
        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N

        cancelButton.setAction(actionMap.get("cancelButton")); // NOI18N
        cancelButton.setName("cancelButton"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N

        canvasSizeButtonGroup.add(size4x6RadioButton);
        size4x6RadioButton.setSelected(true);
        size4x6RadioButton.setText(resourceMap.getString("size4x6RadioButton.text")); // NOI18N
        size4x6RadioButton.setName("size4x6RadioButton"); // NOI18N

        canvasSizeButtonGroup.add(size5x7RadioButton);
        size5x7RadioButton.setText(resourceMap.getString("size5x7RadioButton.text")); // NOI18N
        size5x7RadioButton.setName("size5x7RadioButton"); // NOI18N

        canvasSizeButtonGroup.add(size8x10RadioButton);
        size8x10RadioButton.setText(resourceMap.getString("size8x10RadioButton.text")); // NOI18N
        size8x10RadioButton.setName("size8x10RadioButton"); // NOI18N

        canvasSizeButtonGroup.add(customRadioButton);
        customRadioButton.setText(resourceMap.getString("customRadioButton.text")); // NOI18N
        customRadioButton.setName("customRadioButton"); // NOI18N
        customRadioButton.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                customRadioButtonStateChanged(evt);
            }
        });

        customHSpinner.setEnabled(false);
        customHSpinner.setName("customHSpinner"); // NOI18N

        customWSpinner.setEnabled(false);
        customWSpinner.setName("customWSpinner"); // NOI18N

        heightLabel.setText(resourceMap.getString("heightLabel.text")); // NOI18N
        heightLabel.setName("heightLabel"); // NOI18N

        widthLabel.setText(resourceMap.getString("widthLabel.text")); // NOI18N
        widthLabel.setName("widthLabel"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(customRadioButton)
                            .addComponent(size4x6RadioButton)
                            .addComponent(size5x7RadioButton)
                            .addComponent(size8x10RadioButton)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addComponent(heightLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(customHSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(widthLabel)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(customWSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(size4x6RadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(size5x7RadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(size8x10RadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(customRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(heightLabel)
                    .addComponent(customHSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(customWSpinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(widthLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButton1)
                        .addGap(18, 18, 18)
                        .addComponent(cancelButton)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cancelButton)
                    .addComponent(jButton1))
                .addContainerGap())
        );

        jPanel1.getAccessibleContext().setAccessibleName(resourceMap.getString("jPanel1.AccessibleContext.accessibleName")); // NOI18N

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void customRadioButtonStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_customRadioButtonStateChanged
// TODO add your handling code here:
    if(customRadioButton.isSelected()){
       customHSpinner.setEnabled(true);
       customWSpinner.setEnabled(true);
    } else {
       customHSpinner.setEnabled(false);
       customWSpinner.setEnabled(false);
    }
}//GEN-LAST:event_customRadioButtonStateChanged

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                NewProjectBox dialog = new NewProjectBox(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    @Action
    public void okButton() {
        if(size4x6RadioButton.isSelected()){h = 400; w = 600;}
        else if(size5x7RadioButton.isSelected()){h = 500; w = 700;}
        else if(size8x10RadioButton.isSelected()){h = 800; w = 1000;}
        else if(customRadioButton.isSelected()){
            h = ((Integer)customHSpinner.getValue());
            w = ((Integer)customWSpinner.getValue());
            //h = ((Integer)customHSpinner.getValue())*100;
            //w = ((Integer)customWSpinner.getValue())*100;
            }
        newproj = true;
        setVisible(false);
    }

    @Action
    public void cancelButton() {
        newproj = false;
        setVisible(false);
    }
    public boolean isMakeProj(){
        return newproj;
    }
    public int getW(){return w;}
    public int getH(){return h;}
    

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton cancelButton;
    private javax.swing.ButtonGroup canvasSizeButtonGroup;
    private javax.swing.JSpinner customHSpinner;
    private javax.swing.JRadioButton customRadioButton;
    private javax.swing.JSpinner customWSpinner;
    private javax.swing.JLabel heightLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JRadioButton size4x6RadioButton;
    private javax.swing.JRadioButton size5x7RadioButton;
    private javax.swing.JRadioButton size8x10RadioButton;
    private javax.swing.JLabel widthLabel;
    // End of variables declaration//GEN-END:variables

}
